files <- list.files(path = "tmp", pattern = "*.json", full.names = TRUE)
stopifnot(length(files) > 0)
files## [1] "tmp/BCH.json" "tmp/BCHABC.json" "tmp/BTC.json"
## [4] "tmp/EOS.json" "tmp/ETC.json" "tmp/ETH.json"
## [7] "tmp/LTC.json" "tmp/REP.json" "tmp/XLM.json"
## [10] "tmp/XRP.json" "tmp/ZRX.json"
linear_regression <- function(y) {
x <- 1:length(y) / 60
relation <- lm(y ~ x)
plot(x, y, col = "darkgreen", abline(relation), xlab = "hours", ylab = "USD")
}
# names(prices[,1])
sapply(prices, linear_regression)## $`tmp/BCH.json`
## NULL
##
## $`tmp/BCHABC.json`
## NULL
##
## $`tmp/BTC.json`
## NULL
##
## $`tmp/EOS.json`
## NULL
##
## $`tmp/ETC.json`
## NULL
##
## $`tmp/ETH.json`
## NULL
##
## $`tmp/LTC.json`
## NULL
##
## $`tmp/REP.json`
## NULL
##
## $`tmp/XLM.json`
## NULL
##
## $`tmp/XRP.json`
## NULL
##
## $`tmp/ZRX.json`
## NULL